using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Build.Utilities;

namespace BizTalk.BuildGenerator.Tasks.BRE
{
    /// <summary>
    /// Base task for Business Rules Engine Tasks
    /// </summary>
    public class BaseBRETask : Task
    {
        private string _DatabaseName;
        private string _ServerName;
        private int _MajorVersion = -1;
        private int _MinorVersion = -1;

        /// <summary>
        /// The minor version number
        /// </summary>
        public int MinorVersion
        {
            get { return _MinorVersion; }
            set { _MinorVersion = value; }
        }
        /// <summary>
        /// The major version number
        /// </summary>
        public int MajorVersion
        {
            get { return _MajorVersion; }
            set { _MajorVersion = value; }
        }
        /// <summary>
        /// Indicates if the task is configured to work for a specific version
        /// </summary>
        public bool IsSpecificVersion
        {
            get
            {
                if (this.MajorVersion >= 0 && this.MinorVersion >= 0)
                    return true;
                else
                    return false;
            }
        }

        /// <summary>
        /// Creates the bre manager
        /// </summary>
        /// <returns></returns>
        protected BREManager CreateManager()
        {
            if (!string.IsNullOrEmpty(this._DatabaseName) && !string.IsNullOrEmpty(this._ServerName))
                return new BREManager(this._DatabaseName, this._ServerName);
            else
                return new BREManager();
        }
        /// <summary>
        /// Execute method
        /// </summary>
        /// <returns></returns>
        public override bool Execute()
        {
            return true;   
        }
        /// <summary>
        /// The server name for the BRE database
        /// </summary>
        public string ServerName
        {
            get { return _ServerName; }
            set { _ServerName = value; }
        }
        /// <summary>
        /// The database name for the BRE database
        /// </summary>        
        public string DatabaseName
        {
            get { return _DatabaseName; }
            set { _DatabaseName = value; }
        }

    }
}
